package br.listagem.com;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class AppLista extends Activity {

	public ListView list;

	static final String[] times = new String[] { "Label", "Label", "Label",
			"Label", "Label", "Label", "Label" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lista);

		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, times);
		list = (ListView) findViewById(R.id.list);
		list.setAdapter(adapter);

		list.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				AlertDialog.Builder mensagem = new AlertDialog.Builder(
						AppLista.this);
				mensagem.setTitle("Atenção, você escolheu:");
				mensagem.setMessage(((TextView) view).getText().toString());
				mensagem.setNeutralButton("OK", null);
				mensagem.show();

			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.app_lista, menu);
		return true;
	}

}
